<?xml version="1.0" encoding="ascii"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
          "DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
  <title>bkn.bibtex.utilities</title>
  <link rel="stylesheet" href="epydoc.css" type="text/css" />
  <script type="text/javascript" src="epydoc.js"></script>
</head>

<body bgcolor="white" text="black" link="blue" vlink="#204080"
      alink="#204080">
<!-- ==================== NAVIGATION BAR ==================== -->
<table class="navbar" border="0" width="100%" cellpadding="0"
       bgcolor="#a0c0ff" cellspacing="0">
  <tr valign="middle">
  <!-- Home link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="bkn.bibtex-module.html">Home</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Tree link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="module-tree.html">Trees</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Index link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="identifier-index.html">Indices</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Help link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="help.html">Help</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Project homepage -->
      <th class="navbar" align="right" width="100%">
        <table border="0" cellpadding="0" cellspacing="0">
          <tr><th class="navbar" align="center"
            ><a class="navbar" target="_top" href="http://code.google.com/p/bibkn/">bkn.bibtex</a></th>
          </tr></table></th>
  </tr>
</table>
<table width="100%" cellpadding="0" cellspacing="0">
  <tr valign="top">
    <td width="100%">
      <span class="breadcrumbs">
        Package&nbsp;bkn ::
        <a href="bkn.bibtex-module.html">Package&nbsp;bibtex</a> ::
        Module&nbsp;utilities
      </span>
    </td>
    <td>
      <table cellpadding="0" cellspacing="0">
        <!-- hide/show private -->
        <tr><td align="right"><span class="options">[<a href="javascript:void(0);" class="privatelink"
    onclick="toggle_private();">hide&nbsp;private</a>]</span></td></tr>
        <tr><td align="right"><span class="options"
            >[<a href="frames.html" target="_top">frames</a
            >]&nbsp;|&nbsp;<a href="bkn.bibtex.utilities-module.html"
            target="_top">no&nbsp;frames</a>]</span></td></tr>
      </table>
    </td>
  </tr>
</table>
<!-- ==================== MODULE DESCRIPTION ==================== -->
<h1 class="epydoc">Module utilities</h1><p class="nomargin-top"><span class="codelink"><a href="bkn.bibtex.utilities-pysrc.html">source&nbsp;code</a></span></p>
<p>Useful code which does not fit elsewhere.</p>

<hr />
<div class="fields">      <p><strong>Copyright:</strong>
        (c) 2010, Benjamin Kalish
      </p>
      <p><strong>License:</strong>
        This program is free software; you can redistribute it and/or 
        modify it under the terms of the GNU General Public License as 
        published by the Free Software Foundation; either version 2 of the 
        License, or (at your option) any later version.
        <p>This program is distributed in the hope that it will be useful, 
        but WITHOUT ANY WARRANTY; without even the implied warranty of 
        MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
        General Public License for more details.</p>
      </p>
</div><!-- ==================== CLASSES ==================== -->
<a name="section-Classes"></a>
<table class="summary" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr bgcolor="#70b0f0" class="table-header">
  <td colspan="2" class="table-header">
    <table border="0" cellpadding="0" cellspacing="0" width="100%">
      <tr valign="top">
        <td align="left"><span class="table-header">Classes</span></td>
        <td align="right" valign="top"
         ><span class="options">[<a href="#section-Classes"
         class="privatelink" onclick="toggle_private();"
         >hide private</a>]</span></td>
      </tr>
    </table>
  </td>
</tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">&nbsp;</span>
    </td><td class="summary">
        <a href="bkn.bibtex.utilities.Enumerate-class.html" class="summary-name">Enumerate</a><br />
      Creates a list of named constants which be iterated over.
    </td>
  </tr>
</table>
<!-- ==================== FUNCTIONS ==================== -->
<a name="section-Functions"></a>
<table class="summary" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr bgcolor="#70b0f0" class="table-header">
  <td colspan="2" class="table-header">
    <table border="0" cellpadding="0" cellspacing="0" width="100%">
      <tr valign="top">
        <td align="left"><span class="table-header">Functions</span></td>
        <td align="right" valign="top"
         ><span class="options">[<a href="#section-Functions"
         class="privatelink" onclick="toggle_private();"
         >hide private</a>]</span></td>
      </tr>
    </table>
  </td>
</tr>
<tr class="private">
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">&nbsp;</span>
    </td><td class="summary">
      <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td><span class="summary-sig"><a name="_parent_method"></a><span class="summary-sig-name">_parent_method</span>()</span></td>
          <td align="right" valign="top">
            <span class="codelink"><a href="bkn.bibtex.utilities-pysrc.html#_parent_method">source&nbsp;code</a></span>
            
          </td>
        </tr>
      </table>
      
    </td>
  </tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">&nbsp;</span>
    </td><td class="summary">
      <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td><span class="summary-sig"><a href="bkn.bibtex.utilities-module.html#is_object_unicode_safe" class="summary-sig-name">is_object_unicode_safe</a>(<span class="summary-sig-arg">obj</span>)</span><br />
      Returns <code>True</code> if the passed object contains no String 
      objects.</td>
          <td align="right" valign="top">
            <span class="codelink"><a href="bkn.bibtex.utilities-pysrc.html#is_object_unicode_safe">source&nbsp;code</a></span>
            
          </td>
        </tr>
      </table>
      
    </td>
  </tr>
<tr class="private">
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">&nbsp;</span>
    </td><td class="summary">
      <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td><span class="summary-sig"><a name="_are_sub_objects_unicode_safe"></a><span class="summary-sig-name">_are_sub_objects_unicode_safe</span>(<span class="summary-sig-arg">iterable</span>)</span><br />
      A private method called by is_object_unicode_safe().</td>
          <td align="right" valign="top">
            <span class="codelink"><a href="bkn.bibtex.utilities-pysrc.html#_are_sub_objects_unicode_safe">source&nbsp;code</a></span>
            
          </td>
        </tr>
      </table>
      
    </td>
  </tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">&nbsp;</span>
    </td><td class="summary">
      <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td><span class="summary-sig"><a name="ensure_objects_are_unicode"></a><span class="summary-sig-name">ensure_objects_are_unicode</span>(<span class="summary-sig-arg">*list_of_strings</span>,
        <span class="summary-sig-arg">**map_of_strings</span>)</span></td>
          <td align="right" valign="top">
            <span class="codelink"><a href="bkn.bibtex.utilities-pysrc.html#ensure_objects_are_unicode">source&nbsp;code</a></span>
            
          </td>
        </tr>
      </table>
      
    </td>
  </tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type">&nbsp;</span>
    </td><td class="summary">
      <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td><span class="summary-sig"><a name="assert_objects_are_unicode"></a><span class="summary-sig-name">assert_objects_are_unicode</span>(<span class="summary-sig-arg">*list_of_strings</span>,
        <span class="summary-sig-arg">**map_of_strings</span>)</span></td>
          <td align="right" valign="top">
            <span class="codelink"><a href="bkn.bibtex.utilities-pysrc.html#assert_objects_are_unicode">source&nbsp;code</a></span>
            
          </td>
        </tr>
      </table>
      
    </td>
  </tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type"><code>dict</code></span>
    </td><td class="summary">
      <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td><span class="summary-sig"><a href="bkn.bibtex.utilities-module.html#group" class="summary-sig-name">group</a>(<span class="summary-sig-arg">list</span>,
        <span class="summary-sig-arg">function</span>)</span><br />
      Partitions a list according to the result of the supplied function.</td>
          <td align="right" valign="top">
            <span class="codelink"><a href="bkn.bibtex.utilities-pysrc.html#group">source&nbsp;code</a></span>
            
          </td>
        </tr>
      </table>
      
    </td>
  </tr>
<tr>
    <td width="15%" align="right" valign="top" class="summary">
      <span class="summary-type"><code>str</code></span>
    </td><td class="summary">
      <table width="100%" cellpadding="0" cellspacing="0" border="0">
        <tr>
          <td><span class="summary-sig"><a href="bkn.bibtex.utilities-module.html#which" class="summary-sig-name">which</a>(<span class="summary-sig-arg">program</span>)</span><br />
      Searches for an executable by name or path.</td>
          <td align="right" valign="top">
            <span class="codelink"><a href="bkn.bibtex.utilities-pysrc.html#which">source&nbsp;code</a></span>
            
          </td>
        </tr>
      </table>
      
    </td>
  </tr>
</table>
<!-- ==================== FUNCTION DETAILS ==================== -->
<a name="section-FunctionDetails"></a>
<table class="details" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr bgcolor="#70b0f0" class="table-header">
  <td colspan="2" class="table-header">
    <table border="0" cellpadding="0" cellspacing="0" width="100%">
      <tr valign="top">
        <td align="left"><span class="table-header">Function Details</span></td>
        <td align="right" valign="top"
         ><span class="options">[<a href="#section-FunctionDetails"
         class="privatelink" onclick="toggle_private();"
         >hide private</a>]</span></td>
      </tr>
    </table>
  </td>
</tr>
</table>
<a name="is_object_unicode_safe"></a>
<div>
<table class="details" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr><td>
  <table width="100%" cellpadding="0" cellspacing="0" border="0">
  <tr valign="top"><td>
  <h3 class="epydoc"><span class="sig"><span class="sig-name">is_object_unicode_safe</span>(<span class="sig-arg">obj</span>)</span>
  </h3>
  </td><td align="right" valign="top"
    ><span class="codelink"><a href="bkn.bibtex.utilities-pysrc.html#is_object_unicode_safe">source&nbsp;code</a></span>&nbsp;
    </td>
  </tr></table>
  
  <p>Returns <code>True</code> if the passed object contains no String 
  objects. Unicode objects are allowed.</p>
  <p>This method is useful in avoiding the encoding problems that may occur
  when using byte strings.</p>
  <dl class="fields">
  </dl>
</td></tr></table>
</div>
<a name="group"></a>
<div>
<table class="details" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr><td>
  <table width="100%" cellpadding="0" cellspacing="0" border="0">
  <tr valign="top"><td>
  <h3 class="epydoc"><span class="sig"><span class="sig-name">group</span>(<span class="sig-arg">list</span>,
        <span class="sig-arg">function</span>)</span>
  </h3>
  </td><td align="right" valign="top"
    ><span class="codelink"><a href="bkn.bibtex.utilities-pysrc.html#group">source&nbsp;code</a></span>&nbsp;
    </td>
  </tr></table>
  
  <p>Partitions a list according to the result of the supplied 
  function.</p>
<pre class="py-doctest">
<span class="py-prompt">&gt;&gt;&gt; </span>fruit = [<span class="py-string">'apples'</span>, <span class="py-string">'oranges'</span>, <span class="py-string">'bananas'</span>, <span class="py-string">'coconuts'</span>]
<span class="py-prompt">&gt;&gt;&gt; </span>group(fruit, <span class="py-keyword">lambda</span> x: x[-2])
<span class="py-output">{'a': ['bananas'], 'e': ['apples', 'organges'], 't': ['coconuts']}</span>
<span class="py-output"></span><span class="py-prompt">&gt;&gt;&gt; </span>group(fruit, <span class="py-keyword">lambda</span> x: len(x))
<span class="py-output">{8: ['organges', 'coconuts'], 6: ['apples'], 7: ['bananas']}</span></pre>
  <dl class="fields">
    <dt>Parameters:</dt>
    <dd><ul class="nomargin-top">
        <li><strong class="pname"><code>list</code></strong> (<code>list</code>) - the list to be partitioned</li>
        <li><strong class="pname"><code>function</code></strong> (<code>function</code>) - the function to be used to identify subsets for grouping.</li>
    </ul></dd>
    <dt>Returns: <code>dict</code></dt>
        <dd>a dictionary in which for each key-value pair the value is a list
          such that for each element of that list, <code>i</code>, 
          <code>function(i) == key</code> is true.</dd>
  </dl>
</td></tr></table>
</div>
<a name="which"></a>
<div>
<table class="details" border="1" cellpadding="3"
       cellspacing="0" width="100%" bgcolor="white">
<tr><td>
  <table width="100%" cellpadding="0" cellspacing="0" border="0">
  <tr valign="top"><td>
  <h3 class="epydoc"><span class="sig"><span class="sig-name">which</span>(<span class="sig-arg">program</span>)</span>
  </h3>
  </td><td align="right" valign="top"
    ><span class="codelink"><a href="bkn.bibtex.utilities-pysrc.html#which">source&nbsp;code</a></span>&nbsp;
    </td>
  </tr></table>
  
  <p>Searches for an executable by name or path.</p>
  <p>This function mimics the behavior of the command line utility <a 
  href="http://en.wikipedia.org/wiki/Which_%28Unix%29" 
  target="_top">which</a>.</p>
  <dl class="fields">
    <dt>Parameters:</dt>
    <dd><ul class="nomargin-top">
        <li><strong class="pname"><code>program</code></strong> (<code>str</code>) - the name or path of the desired executable</li>
    </ul></dd>
    <dt>Returns: <code>str</code></dt>
        <dd>the path of to the executable if it exists, otherwise returns 
          <code>None</code></dd>
  </dl>
<div class="fields">      <p><strong>Author:</strong>
        Jay Loden
      </p>
      <p><strong>See Also:</strong>
        <a 
        href="http://stackoverflow.com/questions/377017/test-if-executable-exists-in-python"
        
        target="_top">http://stackoverflow.com/questions/377017/test-if-executable-
        exists-in-python</a>
      </p>
</div></td></tr></table>
</div>
<br />
<!-- ==================== NAVIGATION BAR ==================== -->
<table class="navbar" border="0" width="100%" cellpadding="0"
       bgcolor="#a0c0ff" cellspacing="0">
  <tr valign="middle">
  <!-- Home link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="bkn.bibtex-module.html">Home</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Tree link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="module-tree.html">Trees</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Index link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="identifier-index.html">Indices</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Help link -->
      <th>&nbsp;&nbsp;&nbsp;<a
        href="help.html">Help</a>&nbsp;&nbsp;&nbsp;</th>

  <!-- Project homepage -->
      <th class="navbar" align="right" width="100%">
        <table border="0" cellpadding="0" cellspacing="0">
          <tr><th class="navbar" align="center"
            ><a class="navbar" target="_top" href="http://code.google.com/p/bibkn/">bkn.bibtex</a></th>
          </tr></table></th>
  </tr>
</table>
<table border="0" cellpadding="0" cellspacing="0" width="100%%">
  <tr>
    <td align="left" class="footer">
    Generated by Epydoc 3.0.1 on Sun Jul  4 23:10:58 2010
    </td>
    <td align="right" class="footer">
      <a target="mainFrame" href="http://epydoc.sourceforge.net"
        >http://epydoc.sourceforge.net</a>
    </td>
  </tr>
</table>

<script type="text/javascript">
  <!--
  // Private objects are initially displayed (because if
  // javascript is turned off then we want them to be
  // visible); but by default, we want to hide them.  So hide
  // them unless we have a cookie that says to show them.
  checkCookie();
  // -->
</script>
</body>
</html>
